<meta http-equiv="refresh" content="10;URL=/monitorings">
	<div id ="sub-menu">
		<%= link_to "Afficher les machines", machines_path ,:class => "bouton" %>
		<%= link_to "Afficher les salles", rooms_path ,:class => "bouton" %>
		<%= link_to 'Créer une machine', new_machine_path,:class => "bouton"  %>
		<%= link_to 'Créer une salle', new_room_path,:class => "bouton" %>  
		<div class="bouton"><%= link_to_remote 'Tester la connexion' , :url=>{:action=>"ping_machine"}, :before => "Element.show('wait_icon')", :complete => "Element.hide('wait_icon')" %><%= image_tag "ajax-loader.gif", :id=>"wait_icon", :style=>"display:none" %></div>
	
 	</div>
 	
 <div id="right-menu">
		<table class="table-up">
			<% @up.each do |u| %>
			<tr>
				<th>UP</th>
				<td><%=h u.nb %></td>
			<% end %>		
			</tr>
		</table>
		<table class="table-down">	
			<% @down.each do |d| %>
			<tr>
				<th>DOWN</th>
				<td><%=h d.nb %></td>
			<% end %>		
			</tr>
		</table>	
		<table class="table-warning">	
			<% @warning.each do |w| %>
			<tr>
				<th>WARNING</th>
				<td><%=h w.nb %></td>
			<% end %>		
			</tr>
		</table>
</div>	

	<table class="table">
	  <tr>
		<th>Hôte</th>
		<th>Adresse IP</th>
		<th>Salle</th>
		<th>Etat connectivité</th>
		<th>Information etat</th>
		<th>Last check </th>

	  </tr>
	
	  <% @machines.each do |machine| %>
		  <tr>
		 
		      <td><%=h machine.machine_name %></td>
			  <td><%=h machine.ip_adr %></td>
		      <td><%=h machine.room.room_name %></td>
		      <% state = "#{machine.state_number}" %>
		      <% if state=="1" %>	
			     <td><div class="ping_test" id="up">_</div></td>
			  <% else  %>
			    <td><div class="ping_test" id="down">_</div></td>
			  <% end %>
				<% state_id = "state_#{machine.id}" %>
		      <td><span id=<%= state_id %>><%=h machine.state %></span></td>
		      <td><%=h machine.updated_at %></td>

		  </tr>
	  <% end %>
	</table>
	<hr>
	
	<div id="formulaire1"> <h3> derniers incidents </h3> 
	
	<table class="table">
	  <tr>
		<th>Nom machine</th>
		<th>Adresse IP</th>
		<th>Salle</th>
		<th>Type</th>
		<th>Date </th>
	  </tr>
		  
	  	<% @incidents.each do |inc| %>
		<tr>
	      <td><%=h inc.machine.machine_name %></td>
		  <td><%=h inc.machine.ip_adr %></td>
	      <td><%=h inc.machine.room.room_name %></td>
	      <td><%=h inc.incident_type %></td>
	      <td><%=h date_from_db(inc.created_at) %></td>
		</tr>
		<% end %>
	</table>
</div>
